<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    body{
      margin: 0;
    }
    #box{
      width: 100vw;
      height: 100vh;
    }
  </style>
</head>
<body>
<div id="box">
  <input type="text">
</div>
<script>


  //左键 中健 右键
  window.addEventListener('mousedown',(e)=>{
    console.log('mousedown e:',e)
    console.log('e.button:',e.button)
    //0 是左键
    //1 是中键
    //2 是右键
  })
  window.addEventListener('mouseup',(e)=>{
    console.log('mouseup e:',e)
    console.log('e.button:',e.button) //通mousedown
  })
  //click 只有左键点击会触发(而mousedown和mouseup不论左键中键还是右键都会触发)
  //, 且晚于mouseup触发
  window.addEventListener('click',(e)=>{
    console.log('click e:',e)
    console.log('e.type:',e.type);
    console.log('e.button:',e.button)
  })
  /*这几个点击事件触发顺序依次为
    1. mousedown
    2. mouseup
    3. click
    4. mousedown
    5. mouseup
    6. click
    7. dblclick
  */

  //怎么判断双击？
  window.addEventListener('dblclick',(e)=>{
    console.log('dblclick e:',e)
    console.log('e.type:',e.type);
    console.log('e.button:',e.button)
  })

  // 键盘
  window.addEventListener('keydown',(e)=>{
    console.log('keydown e:',e)
    const data = {
      keyCode: e.keyCode,
      shift: e.shiftKey,
      meta: e.metaKey,
      control: e.ctrlKey,
      alt: e.altKey
    };
    console.log('有用的修饰符:',data);
  })
</script>
</body>
</html>
